package co.fitstart.mobile.web.controller.course;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import co.fitstart.entity.course.round.CourseRound;
import co.fitstart.entity.user.User;
import co.fitstart.mobile.service.CourseRoundService;
import co.fitstart.mobile.web.resolver.Secure;

@Controller
@RequestMapping(value = "/rounds")
public class CoursewareHomeController {
	
	@Autowired
	private CourseRoundService courseRoundService;
	
    @RequestMapping(value = "/{courseRoundId}/courseware/home", method = RequestMethod.GET)
    public ModelAndView list(@Secure User user,
                             @PathVariable("courseRoundId") Long courseRoundId) {
        
        ModelAndView modelAndView = new ModelAndView("course/courseware/courseware-home");
        
        CourseRound courseRound = courseRoundService.loadCourseRound(courseRoundId);
        modelAndView.addObject("courseRound", courseRound);
        return modelAndView;
        
    }
}
